﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.Commerce.Contexts.Countries;
using Kooboo.Commerce.Contexts.Shippings;
using Kooboo.Commerce.Contexts.Payments;

namespace Kooboo.Commerce.Services
{
    public class ItemService : ServiceBase
    {
        public IEnumerable<Tuple<string, string, bool>> GetCountries(string name = null)
        {
            name = name == null ? "" : name;
            return this.Actor.QueryCountries().Select(i => new Tuple<string, string, bool>(i.CountryCode, i.CountryName, name == i.CountryName));
        }

        public IEnumerable<Tuple<string, string, bool>> GetCountriesWithCountyCode(string code = null)
        {
            code = code == null ? "" : code;
            return this.Actor.QueryCountries().Select(i => new Tuple<string, string, bool>(i.CountryCode, i.CountryName, code == i.CountryCode));
        }

        public IEnumerable<Tuple<int, string, bool>> GetShippings(int id = int.MinValue)
        {
            return this.Actor.QueryShippings().Select(i => new Tuple<int, string, bool>(i.Id, i.Name, i.Id == id));
        }

        public IEnumerable<Tuple<string, string, bool>> GetPayments(string name = null)
        {
            name = name == null ? "" : name;
            return this.Actor.QueryPayments().Select(i => new Tuple<string, string, bool>(i.MethodName, i.HeadLine, i.MethodName == name));
        }
    }




}
